package com.li.springbootproject.domain.test;

import com.alibaba.fastjson.JSON;
import com.li.springbootproject.utils.SpringContextUtils;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.TimeUnit;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 6/19/2022 10:22 AM
 */
public class Progress {

    private double progressNum;
    private String message;
    private String uuid;

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public double getProgressNum() {
        return progressNum;
    }

    public void setProgressNum(double progressNum) {
        this.progressNum = progressNum;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void createProgress(Progress progress) {
        RedisTemplate redisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class);
        // 5 秒失效
        redisTemplate.opsForValue().set(progress.getUuid(), JSON.toJSONString(progress), 100000, TimeUnit.MILLISECONDS);
    }
}
